<?

Module::Init('system.structure');
Module::Init('system.fields');


$filter = isset($params['filter']) ? $params['filter'] : false;
$sort = isset($params['sort']) ? $params['sort'] : false;
$bid = $params['block_id'];
$filter[] = array(
    'field' => 'block_id',
    'value' => $bid
);
if(isset($params['section_id'])){
    $filter = array(
        'field' => 'section_id',
        'value' => $params['section_id']
    );
}
$listObj = BDSElement::GetList($filter, $sort);

$elements = array();

while ($element = $listObj->Fetch()) {
    $element['fields'] = Fields::GetFields($element['id'], $element['block_id'], 'E');
    $element['edit_link'] = "/kernel/adm/manageElements.php?action=editelement&bid=".$element['block_id']."&sid=".$element['section_id']."&eid=".$element['id'];
    $elements[] = $element;
}
$result['block_id'] = $params['block_id'];
$result['elements'] = $elements;

